package com.haiyisoft.eclipse.uep.visual.ui.editparts;

import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.List;

import org.eclipse.gef.editparts.AbstractTreeEditPart;

import com.haiyisoft.eclipse.uep.visual.core.model.VisualDiagram;

/**
 * Visual Diagram Tree EditPart
 * 
 * @author sly
 * 
 */
public class VisualDiagramTreeEditPart extends AbstractTreeEditPart implements
		PropertyChangeListener {

	public VisualDiagramTreeEditPart(Object model) {
		super(model);
	}

	public void activate() {
		super.activate();
		((VisualDiagram) this.getModel()).addPropertyChangeListener(this);
	}

	public void deactivate() {
		((VisualDiagram) this.getModel()).removePropertyChangeListener(this);
		super.deactivate();
	}

	@SuppressWarnings("rawtypes")
	protected List getModelChildren() {
		VisualDiagram visualDiagram = ((VisualDiagram) this.getModel());
		return visualDiagram.getChildren();
	}

	public void propertyChange(PropertyChangeEvent evt) {
		refreshChildren();
	}

}
